Add CLI command to generate configs#98
Merged
Merged
Conversation
setuptools_scm 10.0.5 imports parse_version from vcs_versioning, which was removed in vcs_versioning 2.x. Leaving the dependency unpinned made the build backend fail with an ImportError during version inference. Pin it below 2 until setuptools_scm is upgraded. Signed-off-by: cwasicki <126617870+cwasicki@users.noreply.github.com>
Add module-level query helpers to fetch the component IDs of asset meters, inverters, etc. Signed-off-by: cwasicki <126617870+cwasicki@users.noreply.github.com>
load_configs_from_api now builds each config's component-type map straight from the component graph: per type it derives the AC_POWER_ACTIVE formula (skipping empty/zero ones) and the meter/inverter/component ID lists, in a single graph fetch. Replaces the existing funtion to populate formulas. Signed-off-by: cwasicki <126617870+cwasicki@users.noreply.github.com>
asyncclick is only used by the CLI, not the library, so move it out of the core dependencies into a new optional `cli` extra. The render-graph extra now pulls in cli (the render-graph command needs the CLI), and the test extra pulls it in so the cli package stays covered. Install the CLI with `pip install frequenz-gridpool[cli]`. Signed-off-by: cwasicki <126617870+cwasicki@users.noreply.github.com>
Fetch metadata, formulas and component IDs for the given microgrid IDs and print dotted-key TOML to stdout. The command is a thin wrapper over load_configs, supporting a default and override config file. An override file keeps its values where it has them and the API only fills gaps. A default file is overridden by the API. Microgrid IDs default to those found in the files; files are only read. Signed-off-by: cwasicki <126617870+cwasicki@users.noreply.github.com>
load_configs_from_api now derives component IDs alongside formulas (one derive_from_graph flag), and a generate-config CLI command is added. Signed-off-by: cwasicki <126617870+cwasicki@users.noreply.github.com>
Mohammad-Tayyab-Frequenz
approved these changes
Jun 23, 2026
Mohammad-Tayyab-Frequenz
left a comment
Contributor
There was a problem hiding this comment.
LGTM!
Adding it to cli as a separate requirement makes sense. We should also add it to the README.md on how to use it.
Collaborator
Author
Good point, will do a follow-up. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a
generate-configCLI command to derive a microgrid config from the Assets API and prints it as TOML (dotted-key syntax), optionally layering--defaultand--overridefiles by precedence (--default< Assets API <--override).For this, per-type component-ID query helpers are added to the graph generator (
pv_meter_ids,battery_inverter_ids, etc.), which are useful beyond config generation.The
load_configs_from_apifunction now derives per-type formulas and meter/inverter/component IDs from the Assets API component graph, instead of only filling in formulas. The two steps fail independently: a microgrid whose metadata can't be fetched is skipped, while one whose graph can't be derived is still returned with metadata only. Both are logged rather than aborting the batch.Also move CLI deps to an optional
cliextra includingasyncclickand the newtomlkitdep. Install the CLI withpip install frequenz-gridpool[cli]; therender-graphextra pulls it in automatically.